﻿using AutoMapper;
using CustomerService;
using J.Customer.Application.Command.MemberCardCommand;
using J.CustomerGet.Application.Command.CustomerListCommand;
using J.CustomerModel;
using MediatR;

namespace J.Customer.Application.CommandHandler.MemberCardCommandHandler
{
    public class MemberCardAddCommandHandler : IRequestHandler<MemberCardAddCommand, int>
    {
        private readonly IMemberCardService _membercardService;
        private readonly IMapper _mapper;
        public MemberCardAddCommandHandler(IMemberCardService membercardService, IMapper mapper)
        {
            _membercardService = membercardService;
            _mapper = mapper;
        }
        public async Task<int> Handle(MemberCardAddCommand request, CancellationToken cancellationToken)
        {
            MemberCard model = _mapper.Map<MemberCard>(request);
            return await _membercardService.MemberCardAdd(model);
        }
    }
}
